function getUserInfo(){
$.ajax({
  url:'/my/user/userinfo',
  success:function(res){
    console.log(res);
   if (res.status === 0 ) {
     let name = res.data.nickname || res.data.username
     $('.username').text(name)
   }
  if(res.data.user_pic){
    $('.layui-nav-img').attr('src',res.data.user_pic).show()
    $('.text-avatar').hide()
  }
  else{
    let first = res.data.username.substring(0,1).toUpperCase()
    $('.text-avatar').text(first).show()
  }
  }
})
}
getUserInfo()


$('#logout').on('click',function(){
  layer.confirm('确定要退出吗?', function(index){
    //do something
    localStorage.removeItem('token')
    location.href = './index.html'
    layer.close(index);
  });       
})
